<template>

  <div>
    <el-table :data="tableData" border style="width: 100%" height="620px" :fit="true">
      <el-table-column label="序号" type="index" width="50"></el-table-column>
      <el-table-column prop="scriptWritingTitle" label="作品名称" width="200"/>

      <el-table-column prop="tradeId" label="交易哈希" width=""/>

      <el-table-column prop="createTime" label="交易时间" width="160">

      </el-table-column>
      <el-table-column prop="price" label="金额" width="80">
        <template slot-scope="scope">
          <div>{{scope.row.price == null ? '免费' : scope.row.price}}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="primary" @click.stop="submit(scope.row)" v-if="scope.row.tradeState == 2">确认</el-button>
          <div v-else>已确认</div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  import { TradeConfirmedList, AdaPaymentConfirm } from '../../api/TradeInfo'

  export default {
    name: 'index',
    data() {
      return {
        tableData: []
      }
    },
    created() {
      this.getList()
    },
    mounted() {

    },
    methods: {
      getList() {
        TradeConfirmedList().then(res => {
          this.tableData = res.data.list
        })
      },
      submit(row) {
        console.log("xxxxxxxx",row)
        let data = {
          id: row.scriptWritingId,
          payment_id: row.payment_id,
          order_no: row.order_no,
          confirm_amt: row.confirm_amt
        }
        AdaPaymentConfirm(data).then(res => {
          if (res.code == 0) {

            this.getList()
            this.$message({
              message: 'success',
              type: 'success'
            })

          } else {

            this.getList()
            this.$message({
              message: 'warning',
              type: 'warning'
            })

          }
        })

      }
    }
  }
</script>

<style scoped>

</style>
